package com.lmx.repoDomain.repository;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Component;

import com.lmx.common.constants.CommonConstants;
import com.lmx.repoDomain.tmodel.CustomerEvent;

import io.katharsis.repository.annotations.JsonApiResourceRepository;
import io.katharsis.repository.annotations.JsonApiSave;

/**
 * 老人事件
 *
 * @author ytche
 * @date 2017年9月9日
 *
 */
@JsonApiResourceRepository(value = CustomerEvent.class)
@Component
public class CustomerEventRepository extends BaseRepository<CustomerEvent> {
	@PostConstruct
	public void init() {
		super.dslJpaService.setEntityClass(CustomerEvent.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	@JsonApiSave
	public CustomerEvent save(CustomerEvent entity) {
		if (entity.getId() == null) {
			entity.setEventFlag(CommonConstants.DEFAULT_STATUS_YES_1);
		}
		return super.save(entity);
	}
}
